//
//  ZJRecFirstAdvertTableViewCell.m
//  BreadTravel
//
//  Created by 张健 on 15/12/24.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ZJRecFirstAdvertTableViewCell.h"

@implementation ZJRecFirstAdvertTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setView];
    }
    return self;
}

- (void)setView{
    
    self.cover = [[UIImageView alloc]init];
    self.cover.backgroundColor = [UIColor grayColor];
    self.cover.layer.masksToBounds = YES;
    self.cover.layer.cornerRadius = 10;
    [self.contentView addSubview:self.cover];
    [self.cover mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(WIDTH-30);
        make.height.mas_equalTo(190);
    }];
    
    UIView *bgView = [[UIView alloc]init];
    bgView.backgroundColor = [UIColor blackColor];
    bgView.alpha = 0.3;
    bgView.layer.masksToBounds = YES;
    bgView.layer.cornerRadius = 10;
    [self.cover addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.size.equalTo(self.cover);
    }];
    
    self.title = [[UILabel alloc]init];
    self.title.textColor = [UIColor whiteColor];
    self.title.textAlignment = NSTextAlignmentCenter;
    self.title.font = [UIFont systemFontOfSize:19];
    [self.cover addSubview:self.title];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
        make.top.mas_equalTo(190/2-20);
    }];
    
    self.sub_title = [[UILabel alloc]init];
    self.sub_title.textColor = [UIColor whiteColor];
    self.sub_title.font = [UIFont systemFontOfSize:18];
    self.sub_title.textAlignment = NSTextAlignmentCenter;
    [self.cover addSubview:self.sub_title];
    [self.sub_title mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.title.mas_bottom).offset(7);
        make.left.mas_equalTo(30);
        make.right.mas_equalTo(-30);
    }];
    
    
}

-(void)setTableModel:(ZJTableModel *)tableModel{
    
    self.title.text = tableModel.title;
    self.sub_title.text = tableModel.sub_title;
    
    NSURL *url1 = [NSURL URLWithString:tableModel.cover];
    [self.cover sd_setImageWithURL:url1 placeholderImage:IMAGE];
    
}
@end
